package sparkml_study.suijisengling_YuCe

import org.apache.spark.sql.SparkSession

import java.util.Properties

object mysql_to_hive {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .master("local[*]")
      .appName("test")
      .enableHiveSupport()
      .getOrCreate()

    val conn = new Properties()
    conn.setProperty("user", "root")
    conn.setProperty("password", "123456")
    conn.setProperty("driver", "com.mysql.jdbc.Driver")

    spark.read.jdbc("jdbc:mysql://192.168.40.110:3306/animal?useSSL=false","all_data",conn)
      .write.format("hive").mode("overwrite")
      .saveAsTable("animal.all_data")



    spark.close()
  }

}
